//#define __FORCE_TRACE__
//#define __FORCE_distanceEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "math\fn_relPos2D.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private["_position","_distance","_angle","_x","_y","_z","_xout","_yout","_out"];
DEFAULT_PARAM(_position,0,ARR_3(0,0,0));
DEFAULT_PARAM(_distance,1,0);
DEFAULT_PARAM(_angle,2,0);

if (IS_ARRAY(_position)) then {
	_x= GETVAL(_position,0,0); 
	_y= GETVAL(_position,1,0);  
	_z= GETVAL(_position,2,0); 
} else {
	_x = 0;
	_y = 0;
	_z = 0;
};
if (!IS_SCALAR(_distance)) then {
	_distance = 0;
};
if (!IS_SCALAR(_angle)) then {
	_angle = 0;
};

_xout=_x + sin(_angle) * _distance; 
_yout=_y + cos(_angle) * _distance;
_out = [_xout,_yout];
TRACE_1("End",_out);
TMFPROFILERSTOP;
_out;